package com.xudu;

import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.AES;
import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xudu.entity.User;
import com.xudu.service.IUserService;
import com.xudu.utils.AESUtil;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

/**
 * ClassName: testAES
 * Description:
 *
 * @Author xudu
 * @Create 2024/4/18
 */
@SpringBootTest
public class testAES {

    @Autowired
    private IUserService iUserService;

    /**
     * AES加密测试
     */
    @Test
    public void testAES(){
        byte[] encoded = SecureUtil.generateKey(SymmetricAlgorithm.AES.getValue()).getEncoded();
        AES aes = SecureUtil.aes(encoded);
        String s1 = aes.encryptHex("123");
        String s2 = aes.encryptHex("123");
        System.out.println(s1);
        System.out.println(s2);
        //8997a268001f447055a872da1bf079bf
        String s3 = aes.decryptStr(s2);
        System.out.println(s3);
    }



}
